package IOService;

import pojo.Commodity;
import pojo.CommodityList;

import java.util.Scanner;

public class NormalSelectService implements  IOService {
    @Override
    public void work(CommodityList commodityList) {
        Scanner sc= new Scanner((System.in));
        System.out.println("查找的物品");
        String commodityName=sc.nextLine();
        for (int i=0;i<commodityList.getCommdityCount();i++){
            Commodity commodities=commodityList.getCommodities(i);
            if (commodityName.equals(commodities.getName())){
                if (commodities.isBorrow()){
                    System.out.println("已经被买完了");
                    return;
                }else {
                    commodities.setBorrow(true);
                    System.out.println("");
                    return;

                }
            }
        }
    }
}
